package com.xtecher.app.wxapi;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
import com.xtecher.app.R;
import com.xtecher.app.base.BaseActivity;
import com.xtecher.app.base.BaseApplication;

/**
 * Created by Luhao on 2017/2/26.
 */

public class WXEntryActivity extends BaseActivity implements IWXAPIEventHandler {

    private static final String TAG = "wx";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_transparent);
        BaseApplication.wxapi.handleIntent(getIntent(), this);

    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
        BaseApplication.wxapi.handleIntent(intent, WXEntryActivity.this);
    }

    //响应微信请求
    @Override
    public void onReq(BaseReq baseReq) {
    }

    //响应微信回调
    @Override
    public void onResp(BaseResp resp) {
        Log.d(TAG, "onResp: ");
        String result = null;
        switch (resp.errCode) {
            case BaseResp.ErrCode.ERR_OK: {
                result = "分享成功";
            }
            break;
            case BaseResp.ErrCode.ERR_USER_CANCEL:
                result = "分享取消";
                break;
            case BaseResp.ErrCode.ERR_AUTH_DENIED:
                result = "分享被拒绝";
                break;
            default:
                result = "分享返回";
                break;
        }
        showMessage(result);
        finish();

    }
}
